<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .out{
            width: 400px;
            height: 400px;
            background: #aef;
            display:flex;
            justify-content: center;
            align-items: center;
        }
        .inner{
            width: 200px;
            height: 200px;
            background: #cea;
        }
    </style>
</head>
<body>
    <div id="root"></div>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        class App extends React.Component{
            render(){
                return <div className="out" onClick={this.handleClick}>
                        <div className='inner' onClick={this.handleClick2}></div>
                    </div>
            }

            handleClick = (e) => {
                console.log(e.target);
                e.target.style.background = 'black';
            }

            handleClick2 = (e) => {
                console.log(e.target);
                e.target.style.background = 'black';
                //阻止冒泡
                // e.stopPropagation();
            }
        }

        ReactDOM.render(<App />, document.querySelector("#root"));
    </script>
</body>
</html>